<template>
	<scroll-view class="pay_container" scroll-y="true" :enhanced="true" :show-scrollbar="true"
		@scrolltolower="loadMore()">
		<view class="pay_item" v-for="(item,index) in payList" :key="index">
			<view class="pay_content">
				<view class="label">
					<span v-if="item.state == 2">购买礼包</span>
					<span v-if="item.state == 0">下订单</span>
					({{item.name}})
				</view>
				<view class="price">-{{item.total}}</view>
			</view>
			<view class="pay_time">{{item.createTime}}</view> 
		</view>
	</scroll-view>
</template>

<script>
	import { getPaymentRecords } from "../../../api/paymentRecord.js"
	export default {
		data() {
			return {
				pageParam: {
					pageSize:10,
					pageIndex: 1,
				},
				payList: [],
			}
		},
		onShow() {
			this.pageParam.pageIndex = 1
			this.payList = []
			this.getList()
		},
		methods: {
			//获取列表数据
			async getList() {
				const res = await getPaymentRecords(this.pageParam)
				if(res){
					this.payList = this.payList.concat(res.items)
				}else{
					this.payList = []
				}
			},

			//加载更多
			loadMore() {
				this.pageParam.pageIndex++;
				this.getList()
			},
		}
	}
</script>

<style lang="scss" scoped>
	.pay_container {
		width: 100%;
		max-height: 95vh;
		padding: 0 22rpx;
		box-sizing: border-box;

		.pay_item {
			width: 100%;
			height: 130rpx;
			padding: 0 24rpx;
			box-sizing: border-box;
			border-radius: 8rpx;
			border: 1px solid rgb(230, 230, 230);
			box-shadow: 0px 0px 8rpx 0px rgba(0, 0, 0, 0.25);
			margin-top: 34rpx;

			.pay_content {
				width: 100%;
				height: 50%;
				display: flex;
				justify-content: space-between;
				align-items: center;
				border-bottom: 1px dashed rgb(204, 204, 204);
				color: rgb(0, 0, 0);
				font-family: 思源黑体;
				font-size: 28rpx;
				font-weight: 400;

				.price {
					color: rgb(62, 86, 186);
				}
			}
			.pay_time{
				height: 50%;
				display: flex;
				justify-content: flex-end;
				align-items: center;
				color: rgb(183, 183, 183);
				font-family: 思源黑体;
				font-size: 22rpx;
				font-weight: 400;
			}
		}
	}
</style>